$(document).ready(function() {
	search_started = false;
	$('#box_search').click(function() {
		$('#box_search').val("");
		search_started = true;
	});
	$('#btn_left').mouseover(function() {
		//$(this).find('img').stop(false,true).fadeIn(200);
		scroll_left = setInterval(function(){
			position = $('#friends:first').offset().left - $('#friend_container').offset().left;
			//console.log(position);
			if (position < 0) {
				$('#friends').animate({left: '+=200px'} , 1000, 'linear');
			} else {
				$('#friends').stop(true);
				clearInterval(scroll_left);
				scroll_left = false;
			}
		},100);
	});
	$('#btn_right').mouseover(function() {
		//$(this).find('img').stop(false,true).fadeIn(200);
		scroll_right = setInterval(function(){
			position = $('div.item:last').offset().left - $('#friend_container').offset().left;
			//console.log(position);
			//console.log($('div.item:last').attr('id'));
			if (position > 450) {
				$('#friends').animate({left: '-=200px'} , 1000, 'linear');
			} else {
				$('#friends').stop(true);
				clearInterval(scroll_right);
				scroll_right = false;				
			}
		},100);
	});
	$('#btn_right').mouseout(function() {
		//$(this).find('img').stop(false,true).fadeOut(200);
		$('#friends').stop(true);
		clearInterval(scroll_right);
		scroll_right = false;
	});
	$('#btn_left').mouseout(function() {
		//$(this).find('img').stop(false,true).fadeOut(200);
		$('#friends').stop(true);
		clearInterval(scroll_left);
		scroll_left = false;
	});
});